#include <iostream>
using namespace std;
using ll=long long;
int main() {

	ll s=0,sh=0,shy=0;
	int n;
	string str;
	cin>>n>>str;
	for(int i=0;i<static_cast<int>(str.size());++i){
		if(str[i]=='s'){
			++s;
		}
		else if(str[i]=='h'){
			sh+=s;
		}
		else if(str[i]=='y'){
			shy+=sh;
		}
	}
	cout<<shy<<endl;
	
	return 0;
}
